'use strict';

const moment = require('moment')

const db = uniCloud.database();

exports.main = async ({ids}) => {
	const collection = db.collection('projects')
	const res = await collection.get()
	let projects = res.data;
	let project = []

	if(ids){
		ids.forEach( (id) => {
			project.push(projects.find(_project => {
			    return _project.id == id
			}))
		})
	}
	return {
		date: moment().format('YYYY-MM-DD'),
		status: 'success',
		data: project
	}
};
